package main

import "fmt"

type user struct {
	name     string
	password string
}

func (u user) checkPassword(password string) bool { // 类成员函数
	return u.password == password
}

func checkPassword2(u user, password string) bool { // 普通函数
	return u.password == password
}

func (u *user) resetPassword(password string) { // 指针
	u.password = password
}

func main() {
	a := user{name: "wang", password: "1024"}
	a.resetPassword("2048")                // 结构体方法的使用
	fmt.Println(a.checkPassword("2048"))   // true
	fmt.Println(checkPassword2(a, "2048")) // true
}
